const config = require('../config/config');

const axios = require("axios");
const qs = require('qs');
const dataUrl = config.testServer;
module.exports = {
    verifyUser,
    logout,
    resetPassword
}

async function verifyUser(payload){
    let url = dataUrl + "api/v1/common/login"
    let data = qs.stringify({
      'userName': payload.userName,
      'password': payload.password
    });
    
    let config = {
      method: 'post',
      maxBodyLength: Infinity,
      url: url,
      headers: { 
        'Content-Type': 'application/x-www-form-urlencoded'
      },
      data : data
    };
    
    try {
        const result = await axios.request(config)
        return result.data
      } catch (error) {
        return error
      }
    
}

function logout(){
    var result = {
        "status":"success",
        "msg":"logout successfully"
    }
    return result
}

function resetPassword(){
    var result = {
        "status":"failed",
        "msg":"Please contact admin for password change"
    }
    return result
}
